package com.guru.test.twitter;

import java.util.Date;

import twitter4j.DirectMessage;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.conf.ConfigurationBuilder;

/**
 * Example application that sends a message to specified Twitter-er from specified account.<br>
 *
 * @author Yusuke Yamamoto - yusuke at mac.com
 */
public final class SendDirectMessage {
    /**
     * Usage: java twitter4j.examples.directMessage.DirectMessage [recipient screen name] [message]
     *
     * @param args String[]
     */
    public static void main(String[] args) {

    	
    	ConfigurationBuilder cb = new ConfigurationBuilder();
    	cb.setDebugEnabled(true)
    	  .setOAuthConsumerKey("DxI58UW4c0TLTMej5mA-5wA")
    	  .setOAuthConsumerSecret("injaup28WRxUaQOqPRoa5X1gDprXQOslfyaCTVna8m-g")
    	  .setOAuthAccessToken("2404896684-nxo72RugO0Ov9Zi-0XChvfH3IcH6eFGnnOoNvy9Y")
    	  .setOAuthAccessTokenSecret("N6DIPT-opjzy4iOQkds93Jpp3Fuglql14jIw5WGcmXQkOY");
    	TwitterFactory tf = new TwitterFactory(cb.build());
    	Twitter twitter = tf.getInstance();
    	
    	
    	
        //Twitter twitter = new TwitterFactory().getInstance();
        try {
        	
        	String recipient = "@sguruprasanna";
        	String msg =  "["+new Date()+"]"+"Hi!";
            DirectMessage message = twitter.sendDirectMessage(recipient, msg);
            System.out.println("Direct message successfully sent to " + message.getRecipientScreenName());
            System.exit(0);
            //System.out.println();
            //Status status = twitter.updateStatus("["+new Date()+"]"+"Hi!");
            //System.out.println("["+new Date()+"]"+"Successfully updated the status to [" + status.getText() + "].");
            
            
            
            
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to send a direct message: " + te.getMessage());
            System.exit(-1);
        }
    }
}